import request from '@/utils/request'

// 查询订单列表
export function listOrder2() {
  return request({
    url: 'order/order2/list',
    method: 'get'
  })
}

// 根据服务类型ID查询订单信息
export function selectOrderTypeByServiceId(serviceId) {
  return request({
    url: 'order/order2/selectOrderTypeByServiceId',
    method: 'get',
    params: { serviceId: serviceId }
  })
}



// 用户下单
export function insertOrder(data) {
  // 确保数据格式正确
  const orderData = {
    ...data,
    userId: String(data.userId), // 确保 userId 是字符串
    employeeId: String(data.employeeId),
    addressId: String(data.addressId),
    serviceType: data.service_type, // 转换字段名
    serviceContent: data.service_content, // 转换字段名
    homeTime: data.home_time, // 转换字段名
    workTime: data.work_time, // 转换字段名
    priceRangeMin: data.price_range_min, // 转换字段名
    priceRangeMax: data.price_range_max, // 转换字段名
    userRequirement: data.user_requirement // 转换字段名
  };

  return request({
    url: 'order/order2/insertOrder',
    method: 'post',
    data: orderData
  });
}

// 获取服务技能
export function getServiceSkills(serviceId) {
  return request({
    url: 'order/order2/selectSkillsByServiceId',
    method: 'get',
    params: { serviceId }
  })
}
